#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e,part;
  int sum=0;
  cin>>a>>b>>c>>d>>e;
  part=a/3;
  b+=part;
  e+=part;
  sum+=a%3;
  a/=3;
  part=b/3;
  a+=part;
  c+=part;
  sum+=b%3;
  b/=3;
  part=c/3;
  b+=part;
  d+=part;
  sum+=c%3;
  c/=3;
  part=d/3;
  c+=part;
  e+=part;
  sum+=d%3;
  d/=3;
  part=e/3;
  d+=part;
  a+=part;
  sum+=e%3;
  e/=3;
  cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
  cout<<sum;
}